//% color="#3676b8" iconWidth=50 iconHeight=40
namespace yunque{

    //% block="yunque module initialization until successful I2C mode address 0x42" blockType="command" 
    export function init(parameter: any, block: any) {

        Generator.addImport("from DFRobot_Atmospherlum import *");
        Generator.addCode(`yunque_i2c = DFRobot_Atmospherlum_I2C(0x42)
while (yunque_i2c.begin() != 0):
    print("yunque_i2c initialize failed!!")
    time.sleep(1)
print("Sensor initialize success!!")
yunque_i2c.set_local_time()
time.sleep(1)
`);
   
    }

    //% block="yunque get time stamp" blockType="reporter"
    export function getTime(parameter: any, block: any) { 
        Generator.addCode( [`yunque_i2c.get_time_stamp()`,Generator.ORDER_UNARY_POSTFIX]);
   
   } 
    //% block="yunque get [VDAT] value" blockType="reporter"
    //% VDAT.shadow="dropdown"   VDAT.options="VDAT"
    export function getValueDate(parameter: any, block: any) { 
        let dat = parameter.VDAT.code;
        Generator.addCode( [`yunque_i2c.get_value("${dat}")`,Generator.ORDER_UNARY_POSTFIX]);
   
   } 


    //% block="yunque get [UDAT] unit" blockType="reporter"
    //% UDAT.shadow="dropdown"   UDAT.options="UDAT"
    export function getUnitDate(parameter: any, block: any) { 
        let dat = parameter.UDAT.code;
        Generator.addCode( [`yunque_i2c.get_unit("${dat}")`,Generator.ORDER_UNARY_POSTFIX]);
   
   } 
    //% block="yunque get [STR] [VOU]" blockType="reporter"
    //% STR.shadow="string"   STR.defl=" "
    //% VOU.shadow="dropdown"   VOU.options="VOU"
    export function getSingleDate(parameter: any, block: any) { 
        let st = parameter.STR.code;
        let vou = parameter.VOU.code;
        Generator.addCode( [`yunque_i2c.get_${vou}(${st})`,Generator.ORDER_UNARY_POSTFIX]);
   
   } 
/*
    //% block="yunque get all data unit[TOF]" blockType="reporter"
    //% TOF.shadow="dropdown"   TOF.options="TOF"
    export function getAllDate(parameter: any, block: any) { 
        let tof = parameter.TOF.code;
        //tof=tof.replace(/"/g, "")
        Generator.addCode( [`yunque_i2c.get_information(${tof})`,Generator.ORDER_UNARY_POSTFIX]);
   
   } 
*/

}